package com.qianqian.service.utils;

import java.util.HashMap;

public class WxcpTokenCacheTools {

    protected static HashMap<String,String> accessTokenCache = new HashMap<>();
    protected static HashMap<String,Long> expiresTimeCache = new HashMap<>();
    protected static HashMap<String,Integer> expiresInCache = new HashMap<>();

    private static WxcpTokenCacheTools instance = new WxcpTokenCacheTools();
    private WxcpTokenCacheTools(){}

    public synchronized static WxcpTokenCacheTools getWxcpTokenCache() {
        if (instance == null) {
            instance = new WxcpTokenCacheTools();
        }
        return instance ;
    }

    public String getAccessToken(String corpSecret) {
        return accessTokenCache.get(corpSecret);
    }

    public void setAccessToken(String corpSecret,String accessToken) {

        this.accessTokenCache.put(corpSecret,accessToken);
    }

    public long getExpiresTime(String corpSecret) {
        return expiresTimeCache.get(corpSecret);
    }

    public void setExpiresTime(String corpSecret,long expiresTime) {
        this.expiresTimeCache.put(corpSecret,expiresTime);
    }

    public int getExpiresIn(String corpSecret) {
        return expiresInCache.get(corpSecret);
    }

    public void setExpiresIn(String corpSecret,int expiresIn) {
        this.expiresInCache.put(corpSecret,expiresIn);
    }
}
